// 获取当前环境
const getEnv = () => {
  return process.env.NODE_ENV || "production";
};

// 获取基础域名 - uni-app 兼容写法
const getDomain = () => {
  // H5环境下使用window.location
  if (typeof window !== "undefined" && window.location) {
    return `${window.location.protocol}//${window.location.host}`;
  }
  // 或根据实际部署情况设置默认域名
  return "";
};

const _domain = getDomain();
const _gateway = _domain;

export const BASE_URL: any = {
  development: _gateway, // 对应原 dev
  dev: _gateway,
  qa: _gateway,
  production: _gateway,
  buildtest: _gateway,
  custom: _gateway,
};

const env = getEnv();
export const UPLOAD: string = env ? BASE_URL[env] + "/file-api" : "/file-api";
export const HOST: string = BASE_URL[env] || "";
